﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Enterprise.Infrastructure;
using Enterprise.Model.WorkFlow;
using Enterprise.Service.WorkFlow;
namespace Enterprise.UI.Web.Modules.UserConfig
{
    public partial class UserWfConfig : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                OnStart();
            }
        }

        private void OnStart()
        {
            UserWfConfigService cfService = new UserWfConfigService();
            var list = cfService.UserWfConfig(Utility.Get_UserId);
            GridView1.DataSource = list;
            GridView1.DataBind();
        }

        protected void GridView1_OnRowCommand(object sender, GridViewCommandEventArgs e)
        {
            UserWfConfigService cfService = new UserWfConfigService();
            int index = Convert.ToInt32(e.CommandArgument); //获取行号
            int did = (int)GridView1.DataKeys[index].Value;
            var q = cfService.UserWfConfigList().Where(p => p.CID == did).FirstOrDefault();
            if (q != null)
            {
                switch (e.CommandName)
                {
                    case "mDelete":
                        q.DB_Option_Action = "DeleteId";
                        cfService.UserWfConfigExecute(q);
                        break;
                }
                OnStart();
            }
        }

    }
}